package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.dubbo.mapper.QuestionMapper;
import com.tanhua.model.domian.Question;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;



@DubboService
public class QuestionApiImpl implements QuestionApi{
    @Autowired
    private QuestionMapper questionMapper;


    @Override
    public void save(Question question) {
        questionMapper.insert(question);
    }

    @Override
    public void updete(Question question) {
        questionMapper.updateById(question);
    }

    @Override
    public Question findByUserId(Long id) {
        LambdaQueryWrapper<Question> questionLambdaQueryWrapper = new LambdaQueryWrapper<>();
        questionLambdaQueryWrapper.eq(Question::getUserId,id);
        return questionMapper.selectOne(questionLambdaQueryWrapper);
    }
}
